package com.jaychan.controller;

import com.jaychan.oauth.CheckLogin;
import com.jaychan.utils.JwtOperator;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author JayChan
 * @Description
 * @create 2022-01-11 9:15 PM
 */

@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    private JwtOperator jwtOperator;


    @GetMapping("/t")
    @CheckLogin
    public String test(String str){
        return str;
    }


    @GetMapping("/gen-token")
    public String generateToken(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",1);
        map.put("nickname","jaychan");
        map.put("role","user");
        return jwtOperator.generateToken(map);
    }

}
